$(function(){
    let data = AjaxForm('admin/adminList','get');
    let html ='';
    let res = data;
    for (let i=0;i<=res.length-1;i++){
        let status ='';
        if(res[i].status === 1){
            status  = '正常';
        }else{
            status = '异常';
        }
        html += "<tr class=\"table-content\">\n" +
            "<td style=\"width: 5%\">"+res[i].aid+"</td>" +
            "<td style=\"width: 10%\">"+res[i].account+"</td>" +
            "<td style=\"width: 15%\">"+formatDateTime(res[i].log_time)+"</td>" +
            "<td style=\"width: 15%\">"+formatDateTime(res[i].create_time)+"</td>" +
            "<td style=\"width: 10%\">"+status+"</td>" +
            "<td style=\"width: 20%\">"+
            "<!--<a class=\"layui-btn layui-btn-mini\" lay-event=\"detail\">查看</a>-->\n" +
            "<a class=\"update layui-btn layui-btn-mini layui-btn-normal\" ids='"+res[i].aid+"'>编辑</a>"+
            "<a class=\"del    layui-btn layui-btn-mini layui-btn-danger\" ids='"+res[i].aid+"'>删除</a>" +
            "</td>" +
            "</tr>"
    }
    $('.data-table').html(html);
    //todo 编辑
    $('.update').click(function(){
        let id = $(this).attr('ids')
        let urls = "../admin/edit.html?aid="+id;
        layOpen('修改管理信息','50%','300px',urls)
    });

    //todo 删除
    $('.del').click(function(){
        let id = $(this).attr('ids');
        let data = {'aid':id};
        let urls = 'admin/adminDel';
        layFirm('删除',urls,data);
    });
});


$('#btn-add').click(function(){
    let urls = "./create.html";
    layOpen('添加管理员','50%','300px',urls)
});



